﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Gedea.WinForm.Helpers;
using Gedea.WinForm.Forms.Common;
using Gedea.Model.Entities;
using Gedea.Service.Services;

namespace Gedea.WinForm.Forms.Areas
{
    public partial class New : BaseForm
    {
        public delegate void Deleg1();
        public delegate void Deleg2(Area area);
        #region Ctr
        public static New Instance
        {
            get { return ViewLocator<New>.Instance; }
        }

        private New()
        {
            InitializeComponent();
            UserControls.AreaControl control = new UserControls.AreaControl(new Deleg1(CloseApp), new Deleg2(NewArea), false);
            panel1.Controls.Add(control);
        }
        #endregion

        private void New_FormClosed(object sender, FormClosedEventArgs e)
        {
            ViewLocator<New>.CloseInstance = null;
        }

        private void CloseApp()
        {
            this.Close();
        }

        private void NewArea(Area area)
        {
            new AreaService().Add(area);
            MessageBox.Show("El Area ha sido creada con éxito");
            this.Close();
        }

    }
}
